from rest_framework import serializers
from .models import Game,User

# 游戏类的序列化代码
class GameSerializer(serializers.ModelSerializer):
    class Meta:
        model = Game
        fields = ['id', 'name', 'desc', 'user']  # user 是只读主键 ID

# 用户类的序列化代码
class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ['id', 'username', 'password', 'email']